{% extends "./inc/base.html" %}
{% block content %}
                <section class="vbox">
                    <header class="header bg-light dk">
                        <p>{{controller.meta_title}}</p>
                    </header>
                    <section class="scrollable wrapper">

                        <section class="panel panel-default">
                            <header class="panel-heading">
                                订单列表
                                <i data-title="订单状态为已审核时才能发货，审核的订单才能进入执行中。" data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""><i class="fa fa-question-circle"></i></i>
                            </header>
                            <div class="row wrapper">

                                <div class="col-sm-9 m-b-xs">
                                    <div class="btn-group">

                                        <a class="btn btn-sm btn-info {%if status == null %}active{%endif%}" href="/admin/order/list">
                                           全部订单
                                        </a>
                                        <a class="btn btn-sm btn-info {%if status == 2 %}active{%endif%}" href="/admin/order/list/?status=2">
                                           未审核
                                        </a>
                                        <a class="btn btn-sm btn-info {%if status == 3 %}active{%endif%}" href="/admin/order/list/?status=3">
                                           执行中
                                        </a>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group pull-right search-form">
                                        <input type="text" class="input-sm form-control" name="q" placeholder="订单号|会员ID|收货人|收货人电话"
                                               value="{{controller.get('q')}}">
                                        <span class="input-group-btn">
                        <button class="btn btn-sm btn-default" type="button" id="search" url="/admin/order/list/{%if status %}?status=2{% endif %}">搜索</button>
                      </span>
                                    </div>
                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-hover b-t b-light">
                                    <thead>
                                    <tr>
                                        <th style="width:20px;"><label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label></th>
                                        <th>订单号</th>
                                        <th>订单总额</th>
                                        <th>会员账号</th>
                                        <th>收货人</th>
                                        <th>收货人电话</th>
                                        <th>支付方式</th>
                                        <th>支付状态</th>
                                        <th>配送状态</th>
                                        <th>订单状态</th>
                                        <th>操作</th>
                                        <th>打印</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for item in list %}
                                    <tr >
                                        <td><label class="checkbox m-n i-checks"><input class="ids" type="checkbox" name="ids" value="{{item.id}}"><i></i></label></td>
                                         <td>{{item.order_no}}</td>
                                          
                                        <td>￥{{item.order_amount|formatCurrency}}</td>
                                        <td>{{item.user_id|get_nickname}}</td>
                                        <td>{{item.accept_name}}</td>
                                        <td>{{item.mobile}}</td>
                                        <td>{{item.channel}}</td>
                                        <td > {%if item.pay_status == 0%}<span class="text-muted">未支付</span>{%else%}<span class="text-success">已支付</span>{%endif%}</td>
                                        <td >{%if item.delivery_status == 0%}<span class="text-muted">未发货</span> {%else%}<span class="text-success">已发货</span> {%endif%}</td>
                                        
                                        <td class="text-danger">
                                           {%if item.status ==2 %}<span class="text-muted">等待审核 </span>{%elif item.status ==3%}<span class="text-success">已审核</span>{%elif item.status ==6%}<del>已作废</del>{%elif item.status == 4%}<span class="text-primary">已完成</span>{%endif%}
                                        </td>
                                        <td><div class="btn-group">
		                  <button data-toggle="dropdown" class="btn btn-default btn-xs dropdown-toggle"><i class="fa fa-cog"></i> 处理 <span class="caret"></span></button>
		                  <ul class="dropdown-menu dropdown-menu-right">
		                    <li><a href="/admin/order/see/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-eye"></i> 查看</a></li>
		                   {%if item.pay_status !=1 and item.status != 3 and item.delivery_status != 1 and item.status != 4%} <li><a href="/admin/order/edit/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-edit"></i> 编辑</a></li>{%endif%}
                              {%if item.status ==2 %} <li><a href="/admin/order/audit/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-check-square-o"></i> 审核</a></li>
                              {%elif item.status ==3 and item.delivery_status == 0%} <li><a href="/admin/order/ship/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-truck"></i> 发货</a></li>
                              {%endif%}
                              {%if item.status != 6 and item.delivery_status != 2 and item.status ==3%}
                              <li><a href="/admin/order/finish/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-smile-o"></i> 完成</a></li>
                              {%endif%}
                              {%if item.status != 6%}
		                    <li><a href="/admin/order/void/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-trash-o"></i> 作废</a></li>
                              {%endif%}
                              {%if item.status == 6%}
                              <li><a href="/admin/order/del/?id={{item.id}}" class="confirm ajax-get"><i class="fa fa-trash-o"></i> 删除</a></li>
                              {%endif%}
                              <li><a href="/admin/order/remark/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-paperclip"></i> 备注</a></li>
		                  </ul>
		                </div></td>
                                        <td><div class="btn-group dropleft">
		                  <button data-toggle="dropdown" class="btn btn-default btn-xs dropdown-toggle"><i class="fa fa-print"></i> 打印 <span class="caret"></span></button>
		                  <ul class="dropdown-menu dropdown-menu-right">
		                    <li><a href="#"><i class="fa fa-print"></i> 打印订单</a></li>
		                    <li><a href="#"><i class="fa fa-print"></i> 打印购物单</a></li>
		                    <li><a href="#"><i class="fa fa-print"></i> 打印配送单</a></li>
		                    <li><a href="#"><i class="fa fa-print"></i> 打印快递单</a></li>
		                  </ul>
		                </div></td>
                                    </tr>
                                    {% else %}
                                    <tr><td colspan="11"><div class="alert alert-warning alert-block">
                                        <button data-dismiss="alert" class="close" type="button">×</button>
                                        <p>This would display if the 'item' collection were empty</p>
                                    </div></td></tr>

                                    {% endfor %}


                                    </tbody>
                                </table>
                            </div>
                            <footer class="panel-footer">
                                <div class="row">


                                    <div class="col-sm-12 text-right text-center-xs">
                                        {{pagerData | safe}}
                                    </div>
                                </div>
                            </footer>
                        </section>
                    </section>
                </section>

{% endblock %}
{% block script%}
<script src="/static/admin/js/parsley/parsley.min.js"></script>
<script src="/static/admin/js/parsley/parsley.extend.js"></script>
<script>
    $(function () {
      //搜索功能
      $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
          url += '&' + query;
        }else{
          url += '?' + query;
        }
        window.location.href = url;
      });

      //回车自动提交
      $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
          $("#search").click();
        }
      });

    })
</script>
{% endblock%}